#ifndef __FSM_TIMER_H__
#define __FSM_TIMER_H__

#include "stdint.h"
#include "fsm_list.h"

typedef void (*timer_func)(void);

typedef enum {
    fsm_timer_one_flg = 1,
    fsm_timer_period_flg,
} timer_ctr;

typedef struct fsm_timer {
    uint32_t    nTicks;
    uint32_t    interval;
    timer_ctr   ctr;        // 控制方式
    timer_func  entry;      // 回调函数
    
    rt_list_t   tlist;      /* 线程链表节点 */
} fsm_timer_t;

void fsm_timer_init(fsm_timer_t *timer, timer_func entry, uint32_t nTicks, timer_ctr flg);
void fsm_timer_set(fsm_timer_t *timer, uint32_t nTicks, timer_ctr flg);
int  fsm_timer_start(fsm_timer_t *timer, uint32_t nTicks);
int  fsm_timer_stop(fsm_timer_t *timer);

void fsm_system_timer_init(uint32_t nTicks);
void fsm_timer_handler(void);

extern void fsm_system_timer(void);

#endif
